$(
    function ()
    {
        $(".login-btn>.login-btn-left").on("click",function ()
        {
            var username=$("input[name='username']").val();
            var password=$("input[name='password']").val();

            if(!username)
            {
                alert("请输入用户名!")
                return;
            }

            if (!password)
            {
                alert("请输密码!");
                return;
            }

            $.post("/login",{"username":username,"password":password},function (data)
            {
                if(data.code==200)
                {
                    layui.data('user', {
                        key: 'userkey'
                        ,value: JSON.stringify(data)
                    });
                    window.location.href="/"
                }else
                {
                    alert("登录失败，用户或密码错误!");
                }
            })

        })
    }
)